home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / rjcom.exe / COM.TXT < prev    next >
Encoding:
Text File  |  1991-12-14  |  57.8 KB  |  2,043 lines

  1.  
  2.  
  3.  
  4.         
  5.         
  6.                              COM.LIB communications
  7.         
  8.         
  9.         The functions described in this document allow a C program to set 
  10.         up  and control communications that will take place  through  the 
  11.         serial  ports.  The routines are found in the  library  COM_S.LIB 
  12.         for  small model or COM_L for the large C model. The  initializa-
  13.         tion  function sets up an ISR that handles  communications.   The 
  14.         ISR  takes  the place of INT-14 and supports up  to  four  serial 
  15.         interfaces.  COM.LIB supports both IRQ-3 and IRQ-4  for  transmit 
  16.         and receive and also supports other enhanced commands for the COM 
  17.         ports.  In addition to this file, INT_14.H is a header file  that 
  18.         must  be  included.  It contains the  necessary  definitions  for 
  19.         communication  port  data  transfers done with  this  library  of 
  20.         routines.
  21.         
  22.         INT_14.H  specify  four typedefs that will  be  used  extensively 
  23.         throughout this document.  They are as follows:
  24.         
  25.              typedef unsigned char    uc;
  26.              typedef unsigned int     ui;
  27.              typedef unsigned long    ul;
  28.              typedef unsigned short   us;
  29.         
  30.         These storage classes have been defined in this manner to facili-
  31.         tate  casting  operations and to eliminate keystrokes  in  normal 
  32.         declarations.
  33.         
  34.         It should be noted that the variable cn, used extensively in  the 
  35.         following  definitions  to symbolize the com_number,  is  of  the 
  36.         following format:
  37.                ( COM1 = 0, COM2 = 1, COM3 = 2, COM4 = 3, etc... )
  38.         
  39.         There are several shorthand notations used in this document.
  40.         They are listed here:
  41.         
  42.              ->        points to
  43.              LSBit     least significant bit
  44.              MSBit     most significant bit
  45.              LSByte    least significant byte
  46.              MSByte    most significant byte
  47.         
  48.         There  are several error codes that may be returned by  functions 
  49.         described in this document.  They are listed below:
  50.         
  51.              NO_ERROR                  0
  52.              ILLEGAL_COM_PORT         -1
  53.              INPUT_QUEUE_EMPTY        -2
  54.              OUTPUT_QUEUE_FULL        -3
  55.              ERROR_BAUD_RATE          -4
  56.              ERR_HSK_IN_PLACE         -6
  57.              ERR_BAD_DATA             -7
  58.              ERR_CARRIER_DROPPED      -8
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.         
  66.         Global Variables
  67.         --------------------------------------------------------
  68.         
  69.         There are a few global variables that may be viewed or altered by 
  70.         the application.  Because the serial ports are interrupt  driven, 
  71.         any accesses made with a variable that is above 16-bits should be 
  72.         made only while interrupts are disabled.
  73.         
  74.         
  75.         us _Com_Cprint_Output
  76.         
  77.         This  is  a bit field that determines the device that  the  bytes 
  78.         that are sent out through cprint().  If bit 0 is set,  characters 
  79.         will be sent to the display console.  If bit 1 is set, the  char-
  80.         acters are sent to the COM number held in _Cprint_Cn.  Any combi-
  81.         nation of these bits may be set or cleared.
  82.         
  83.         
  84.         us _Com_Error_Count[]
  85.         
  86.         This  is  an array that contains the number of  error  conditions 
  87.         that have happened for each of the COM ports.
  88.         
  89.         
  90.         ul _Com_Total_In
  91.         
  92.         This  contains the total number of bytes that have been  received 
  93.         from all the COM ports combined.
  94.         
  95.         
  96.         ul _Com_Total_Out
  97.         
  98.         This  contains the total number of bytes that have been sent  out 
  99.         all the COM ports combined.
  100.         
  101.         
  102.         us Com_Xfer_Timeout
  103.         
  104.         Default number of system ticks between sequential transmitted  or 
  105.         received  characters before modem style functions  (ie  cprint()) 
  106.         return a timeout error.
  107.         
  108.         
  109.         us _Cprint_Cn
  110.         
  111.         This is the COM number that cprint() uses to communicate through.
  112.         
  113.         
  114.         us _Xon_Percent
  115.         
  116.         This  is  the  percentage of the input buffer that  can  be  full 
  117.         before the ISR sends an XON to the remote.
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.         
  125.         Global Variables   (cont.)
  126.         --------------------------------------------------------
  127.         
  128.         us _Xoff_Percent
  129.         
  130.         This is the percentage of the input buffer that can be full  when 
  131.         the ISR sends an XOFF to the remote.
  132.         
  133.         
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.         
  141.         com_assert_dtr 
  142.         --------------------------------------------------------
  143.         
  144.         
  145.              Summary
  146.         
  147.              #include <int_14.h>
  148.         
  149.              short com_assert_dtr( cn );
  150.              us cn;         The COM port to initialize 
  151.         
  152.         
  153.         
  154.              Description
  155.         
  156.              This function asserts the data terminal ready signal ( DTR ) 
  157.              on the specified COM port cn. Asserting this signal  usually 
  158.              informs  a modem that the computer is powered up  and  ready 
  159.              for communications.
  160.         
  161.         
  162.         
  163.              Return Value
  164.         
  165.              The function returns a zero if completed, else the appropri-
  166.              ate error code is returned
  167.         
  168.         
  169.              See Also
  170.         
  171.              com_drop_dtr
  172.               
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.         
  180.         com_assert_rts 
  181.         --------------------------------------------------------
  182.         
  183.         
  184.              Summary
  185.         
  186.              #include <int_14.h>
  187.         
  188.              short com_assert_rts( cn );
  189.              us cn;         The COM port to initialize 
  190.         
  191.         
  192.         
  193.              Description
  194.         
  195.              This  function  asserts the request to send ( RTS )  on  the 
  196.              specified COM port cn. Asserting this signal may inform  the 
  197.              modem or other system that you want to send data.  In  hard-
  198.              ware handshaking, asserting this signal is used to tell  the 
  199.              sending system to send data.
  200.         
  201.         
  202.         
  203.              Return Value
  204.         
  205.              The function returns a zero if completed, else the appropri-
  206.              ate error code is returned
  207.         
  208.         
  209.              See Also
  210.         
  211.              com_drop_dtr
  212.               
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.         
  220.         com_clear_input     
  221.         ----------------------------------------------------------------
  222.         
  223.         
  224.              Summary
  225.              
  226.              #include <int_14.h>
  227.         
  228.              short com_clear_input( cn );
  229.              us cn;              The COM port to initialize 
  230.         
  231.         
  232.         
  233.              Description
  234.         
  235.              This  function  clears the input buffer that  is  associated 
  236.              with the COM port cn.  The input buffer holds the bytes that 
  237.              are received by the port but have not yet been retrieved  by 
  238.              the  input routines.  Clearing this buffer will destroy  any 
  239.              data that has been received and not retrieved.
  240.         
  241.         
  242.         
  243.              Return Value
  244.         
  245.              This  routine returns a zero if all went OK, else a  comple-
  246.              tion code will be returned explaining the error.
  247.         
  248.         
  249.         
  250.              See Also
  251.         
  252.              com_clear_output
  253.               
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.         
  261.         com_clear_output    
  262.         ----------------------------------------------------------------
  263.         
  264.         
  265.              Summary
  266.         
  267.              #include <int_14.h>
  268.         
  269.              short com_clear_output( cn );
  270.              us cn;              The COM port to initialize 
  271.         
  272.         
  273.         
  274.              Description
  275.         
  276.              This  function clears the output buffer that  is  associated 
  277.              with  the  COM port cn.  The output buffer holds  the  bytes 
  278.              that are to be sent in order to the port for output as  soon 
  279.              as it becomes available.
  280.         
  281.         
  282.         
  283.              Return Value
  284.         
  285.              This  function returns a zero if all is OK, else the  appro-
  286.              priate completion code is returned.
  287.         
  288.         
  289.              See Also
  290.         
  291.              com_clear_input
  292.               
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.         
  300.         com_drop_dtr   
  301.         ----------------------------------------------------------------
  302.         
  303.         
  304.              Summary
  305.         
  306.              #include <int_14.h>
  307.         
  308.              short com_drop_dtr( cn );
  309.              us cn;         The COM port to initialize 
  310.         
  311.              
  312.         
  313.              Description
  314.         
  315.              This  function drops the data terminal ready signal ( DTR  ) 
  316.              of the specified COM port cn.  Dropping this signal  usually 
  317.              informs  a  connected modem that the computer is  no  longer 
  318.              ready for communications.
  319.         
  320.         
  321.         
  322.              Return Value
  323.         
  324.              The  function  returns the MSBit = 1 if there is  an  error, 
  325.              otherwise  the status  is returned, with the MSByte =  modem 
  326.              status, and the LSByte = line status.
  327.         
  328.         
  329.         
  330.              See Also
  331.         
  332.              com_assert_dtr
  333.               
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.         
  341.         com_drop_rts   
  342.         --------------------------------------------------------
  343.         
  344.         
  345.              Summary
  346.         
  347.              #include <int_14.h>
  348.         
  349.              short com_drop_rts( cn );
  350.              us cn;         The COM port to initialize 
  351.         
  352.         
  353.         
  354.              Description
  355.         
  356.              This  function  drops  the request to send ( RTS  )  on  the 
  357.              specified COM port cn. Asserting this signal may inform  the 
  358.              modem or other system that you want to send data.  In  hard-
  359.              ware handshaking, asserting this signal is used to tell  the 
  360.              sending  system to send data and dropping the  signal  tells 
  361.              the sending computer to stop sending data.
  362.         
  363.         
  364.         
  365.              Return Value
  366.         
  367.              The function returns a zero if completed, else the appropri-
  368.              ate error code is returned
  369.         
  370.         
  371.              See Also
  372.         
  373.              com_drop_dtr
  374.               
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.         
  382.         com_ein   
  383.         ----------------------------------------------------------------
  384.         
  385.         
  386.              Summary
  387.         
  388.              #include <int_14.h>
  389.         
  390.              us com_ein( cn );
  391.              us cn;              The COM port to initialize 
  392.         
  393.         
  394.         
  395.              Description
  396.         
  397.              This function gets the number of bytes that are still unused 
  398.              in the input buffer of the given COM port cn.
  399.         
  400.         
  401.         
  402.              Return Value
  403.         
  404.              There  is  no error condition here, a bad cn  will  yield  a 
  405.              return  of zero, if a good com number is given the  returned 
  406.              value is the number of bytes in the input buffer.
  407.         
  408.         
  409.         
  410.              See Also
  411.         
  412.              com_qout com_eout com_qin
  413.               
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.         
  421.         com_eout  
  422.         ----------------------------------------------------------------
  423.         
  424.         
  425.              Summary
  426.         
  427.              #include <int_14.h>
  428.         
  429.              us com_eout( cn );
  430.              us cn;              The COM port to initialize 
  431.         
  432.         
  433.         
  434.              Description
  435.         
  436.              This function gets the number of bytes that are still unused 
  437.              in the output buffer of the given COM port cn.
  438.         
  439.         
  440.         
  441.              Return Value
  442.         
  443.              There  is  no error condition here, a bad cn  will  yield  a 
  444.              zero.   The  returned value in all other cases will  be  the 
  445.              number of bytes contained in the output buffer.
  446.         
  447.         
  448.         
  449.              See Also
  450.         
  451.              com_qin com_qout com_ein
  452.               
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.         
  460.         com_get_settings    
  461.         ----------------------------------------------------------------
  462.         
  463.         
  464.              Summary
  465.         
  466.              #include <int_14.h>
  467.         
  468.              short com_get_settings( cn, baud_rate, data_size, stop_bits, 
  469.                                      parity );
  470.              us cn;              The COM port to initialize 
  471.              ul *baud_rate;      -> the variable to place the baud_rate
  472.              uc *data_size;      -> the variable to place the data_size
  473.              uc *stop_bits;      -> the variable to place the stop_bits
  474.              uc *parity;         -> the variable to place the parity
  475.         
  476.         
  477.         
  478.              Description
  479.         
  480.              This function places the current COM port cn settings in the 
  481.              variables that are provided. The baud rate 110 - 38400  will 
  482.              be placed into baud_rate, and the data size between 5 and  8 
  483.              bits  will be put into data_size.  The amount of stop  bits, 
  484.              either  one  or two, will be placed into stop_bits  and  the 
  485.              type of parity, either 1, 2, or 3 meaning none, odd, or even 
  486.              will be put into parity.
  487.         
  488.         
  489.         
  490.              Return Value
  491.         
  492.              This function returns the character if one is ready, and  if 
  493.              one  is not, it will return an INPUT_QUEUE_EMPTY  completion 
  494.              code
  495.         
  496.         
  497.              See Also
  498.         
  499.              com_status com_init
  500.               
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.         
  508.         com_in    
  509.         ----------------------------------------------------------------
  510.         
  511.         
  512.              Summary
  513.         
  514.              #include <int_14.h>
  515.         
  516.              short com_in( cn );
  517.              us cn;              The COM port to initialize 
  518.         
  519.         
  520.         
  521.              Description
  522.         
  523.              This function inputs a character from the com number cn that 
  524.              is  specified.  It will get the byte of data from the  input 
  525.              buffer  if a byte is ready.  As the bytes actually  come  to 
  526.              the  receiving  port,  they are stored in a  buffer  till  a 
  527.              function such as this one remove them from it.
  528.         
  529.         
  530.         
  531.              Return Value
  532.         
  533.              This function returns the character if one is ready, and  if 
  534.              one  is not, it will return an INPUT_QUEUE_EMPTY  completion 
  535.              code
  536.         
  537.         
  538.              See Also
  539.         
  540.              com_sin com_snin com_qin com_ein
  541.               
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.         
  549.         com_init  
  550.         ----------------------------------------------------------------
  551.              
  552.         
  553.              Summary
  554.         
  555.              #include <int_14.h>
  556.         
  557.              short com_init( cn, baud_rate, data_size, stop_bits, parity,
  558.                              loopback_test );
  559.              us cn;              The COM number to initialize 
  560.              ul baud_rate;       The Baud rate to be set at installation
  561.              uc data_size;       Size of a data word, 5-8 bits
  562.              uc stop_bits;       The number of stop bits, 1 or 2
  563.              uc parity;          Parity to use with communication
  564.              ui loopback_test;   The port and interrupt are verified
  565.         
  566.         
  567.         
  568.              Description
  569.         
  570.              This function initializes the cn to the values given by  the 
  571.              rest  of  the calling parameters.  The  baud_rate  is  first 
  572.              given  and  can  be a value between  110  and  38,400.   The 
  573.              data_size can be either a 5, 6, 7, or 8 and it specifies how 
  574.              many  bits  to  include  in  each  word  transferred.    The 
  575.              stop_bits  should be either a 1 or 2 and the parity  can  be 
  576.              either  none, odd, or even given as 0, 1 or 2  respectively.  
  577.              The  loopback_test the number of bytes to send in a test  of 
  578.              the  serial port and interrupt.  If this value  is  non-zero 
  579.              then the port is temporarily put into the loopback mode  and 
  580.              the  number  given by loopback_test is the amount  of  bytes 
  581.              that are looped back and checked for validity in the test.
  582.         
  583.         
  584.         
  585.              Return Value
  586.         
  587.              This function returns a zero no errors were encountered, and 
  588.              a error code will be returned if there was one.
  589.         
  590.         
  591.         
  592.              See Also
  593.         
  594.              com_status 
  595.               
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.         
  603.         com_hangup     
  604.         ----------------------------------------------------------------
  605.              
  606.         
  607.              Summary
  608.         
  609.              #include <int_14.h>
  610.         
  611.              short com_hangup( cn )
  612.              us cn;              COM number to hangup
  613.         
  614.         
  615.         
  616.              Description
  617.         
  618.              This function attempts to hangup a phone line connected to a 
  619.              Hayes compatible modem.  It attempts this by first  dropping 
  620.              DTR for one second.  If DCD is still asserted,  com_hangup() 
  621.              sends a hangup command to the modem after attempting to  put 
  622.              the  modem in command mode ("+++\nATH0\n").  If  carrier  is 
  623.              still active, com_hangup() returns with an error code.
  624.         
  625.         
  626.         
  627.              Return Value
  628.         
  629.              This function returns a zero no errors were encountered, and 
  630.              a error code will be returned if there was one.
  631.         
  632.         
  633.         
  634.              See Also
  635.         
  636.              com_init
  637.               
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.         
  645.         com_out
  646.         ----------------------------------------------------------------
  647.         
  648.         
  649.              Summary
  650.         
  651.              #include <int_14.h>
  652.         
  653.              short com_out( cn, output_char );
  654.              us cn;              The COM number to initialize 
  655.              uc output_char;     The character to output
  656.         
  657.         
  658.         
  659.              Description
  660.         
  661.              This function outputs a character, given as  output_char. It 
  662.              does  this  by putting the byte into the output  queue.   If 
  663.              there  already  is a byte waiting to be output then  a  byte 
  664.              would be stored in the output buffer and output in its turn.
  665.         
  666.         
  667.         
  668.              Return Value
  669.         
  670.              This  function  returns a 0 if no errors  were  encountered, 
  671.              else the appropriate completion code will be returned.
  672.         
  673.         
  674.         
  675.              See Also
  676.         
  677.              com_sout com_snout com_qout com_send_command
  678.               
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.         
  686.         com_qin   
  687.         ----------------------------------------------------------------
  688.         
  689.         
  690.              Summary
  691.         
  692.              #include <int_14.h>
  693.         
  694.              us com_qin( cn );
  695.              us cn;              The COM port to initialize 
  696.         
  697.         
  698.         
  699.              Description
  700.         
  701.              This function gets the number of bytes that are queued up in 
  702.              the input buffer of the given COM port cn.
  703.         
  704.         
  705.         
  706.              Return Value
  707.         
  708.              There  is  no error condition here, a bad cn  will  yield  a 
  709.              return  of zero, if a good com number is given the  returned 
  710.              value is the number of bytes in the input buffer.
  711.         
  712.         
  713.         
  714.              See Also
  715.         
  716.              com_qout com_eout com_ein
  717.               
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.         
  725.         com_qout  
  726.         ----------------------------------------------------------------
  727.         
  728.         
  729.              Summary
  730.         
  731.              #include <int_14.h>
  732.         
  733.              us com_qout( cn );
  734.              us cn;              The COM port to initialize 
  735.         
  736.         
  737.         
  738.              Description
  739.         
  740.              This function gets the number of bytes that are queued up in 
  741.              the output buffer of the given COM port cn.
  742.         
  743.         
  744.         
  745.              Return Value
  746.         
  747.              There  is  no error condition here, a bad cn  will  yield  a 
  748.              zero.   The  returned value in all other cases will  be  the 
  749.              number of bytes contained in the output buffer.
  750.         
  751.         
  752.         
  753.              See Also
  754.         
  755.              com_qin com_eout com_ein
  756.               
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.         
  764.         com_pulse_dtr  
  765.         ----------------------------------------------------------------
  766.         
  767.         
  768.              Summary
  769.              
  770.              #include <int_14.h>
  771.         
  772.              short com_pulse_dtr( cn, milliseconds );
  773.              us cn;              The COM port to initialize 
  774.              us milliseconds;    The amount of time to drop DTR
  775.         
  776.         
  777.         
  778.              Description
  779.         
  780.              This  function  first drops the DTR  (data  terminal  ready) 
  781.              signal  for  an amount of time denoted by  milliseconds  and 
  782.              then reasserts DTR.  This is done to the COM port associated 
  783.              with the COM number cn
  784.         
  785.         
  786.         
  787.              Return Value
  788.         
  789.              This function returns a completion code of zero if all  went 
  790.              OK, or else a negative error code will be returned.
  791.         
  792.         
  793.         
  794.              See Also
  795.         
  796.              com_drop_dtr com_assert_dtr
  797.               
  798.  
  799.  
  800.  
  801.  
  802.  
  803.  
  804.         
  805.         com_restore_input   
  806.         ----------------------------------------------------------------
  807.         
  808.         
  809.              Summary
  810.              
  811.              #include <int_14.h>
  812.         
  813.              short com_restore_input( cn );
  814.              us cn;              The COM port to initialize 
  815.         
  816.         
  817.         
  818.              Description
  819.         
  820.              This function returns the input buffer to its original  area 
  821.              and size.  All that need be specified is the COM port  given 
  822.              by  cn.  All the internal input buffer pointers are  set  to 
  823.              the empty condition and the default buffer area.  
  824.         
  825.         
  826.         
  827.              Return Value
  828.         
  829.              This function returns a completion code of zero if all  went 
  830.              OK, or else a negative error code will be returned.
  831.         
  832.         
  833.         
  834.              See Also
  835.         
  836.              com_set_input com_set_output com_restore_output
  837.               
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.         
  845.         com_restore_output  
  846.         ----------------------------------------------------------------
  847.         
  848.         
  849.              Summary
  850.              
  851.              #include <int_14.h>
  852.         
  853.              short com_restore_output( cn );
  854.              us cn;         The COM port to initialize 
  855.         
  856.         
  857.         
  858.              Description
  859.         
  860.              This function returns the output buffer to its original area 
  861.              and size.  All that need be specified is the COM port speci-
  862.              fied  by cn.  The internal buffer pointers are reset to  the 
  863.              original default buffer area and also to the empty condition
  864.         
  865.         
  866.         
  867.              Return Value
  868.         
  869.              This function returns a completion code of zero if all  went 
  870.              OK, or else a negative error code will be returned.
  871.         
  872.         
  873.         
  874.              See Also
  875.         
  876.              com_set_input com_set_output com_restore_input
  877.               
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.         
  885.         com_send_command    
  886.         ----------------------------------------------------------------
  887.         
  888.         
  889.              Summary
  890.              
  891.              #include <int_14.h>
  892.         
  893.              short com_send_command( cn, cmd_string );
  894.              us cn;                   The COM port to initialize 
  895.              uc far *cmd_string;      -> the ASCIIZ string to send out 
  896.         
  897.         
  898.         
  899.              Description
  900.         
  901.              The  purpose of this function is to allow a user to  send  a 
  902.              command  string to a modem or other device at the slow  rate 
  903.              that  the  device requires.  This function sends  the  given 
  904.              cmd_string out at the rate of one byte every so many  system 
  905.              ticks to the given COM port cn.  This function waits for the 
  906.              output  buffer  to  clear before it sends  any  data.   Some 
  907.              special  characters may be used in the cmd_string  and  will 
  908.              have the following definition:
  909.         
  910.                   | = carriage return (13)
  911.                   ~ = delay one system tick
  912.                   ^ = raise DTR
  913.                   ` = lower DTR
  914.                   / = next character is taken literally
  915.         
  916.         
  917.         
  918.              Return Value
  919.         
  920.              This function returns a completion code of zero if all  went 
  921.              OK, or else a negative error code will be returned.
  922.         
  923.         
  924.         
  925.              See Also
  926.         
  927.              com_out com_sout com_snout
  928.               
  929.  
  930.  
  931.  
  932.  
  933.  
  934.  
  935.         
  936.         com_set_baud   
  937.         ----------------------------------------------------------------
  938.         
  939.         
  940.              Summary
  941.              
  942.              #include <int_14.h>
  943.         
  944.              short com_set_baud( cn, baud_rate);
  945.              us cn;              The COM port to initialize 
  946.              ul baud_rate;       The baud rate value to set
  947.         
  948.         
  949.         
  950.              Description
  951.         
  952.              This  function sets the baud_rate to the given  value.   The 
  953.              operation  is done to the COM port, cn.  Possible values  of 
  954.              baud_rate  extend  from 110 to 38400 baud  in  the  discrete 
  955.              values described below.
  956.         
  957.                   110       9600
  958.                   300       11500
  959.                   600       38400
  960.                   1200
  961.                   2400
  962.                   4800
  963.         
  964.          
  965.         
  966.              Return Value
  967.         
  968.              This function returns a completion code of zero if all  went 
  969.              OK, or else a negative error code will be returned.
  970.         
  971.         
  972.         
  973.              See Also
  974.         
  975.              com_init com_set_datasize
  976.         
  977.               
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.         
  985.         com_set_carrier_vector   
  986.         ----------------------------------------------------------------
  987.         
  988.         
  989.              Summary
  990.              
  991.              #include <int_14.h>
  992.         
  993.              short com_set_carrier_vector( cn, (*function)() );
  994.              us cn;              The COM port to initialize 
  995.              us *function;       -> the function to call
  996.         
  997.         
  998.         
  999.              Description
  1000.         
  1001.              This  function sets the vector to call whenever a change  in 
  1002.              carrier  is  detected by the COM port, cn.   The  vector  is 
  1003.              called  with all registers saved and the function  must  not 
  1004.              return using a iret, is must use a ret instruction.
  1005.         
  1006.          
  1007.         
  1008.              Return Value
  1009.         
  1010.              This function returns a completion code of zero if all  went 
  1011.              OK, or else a negative error code will be returned.
  1012.         
  1013.         
  1014.         
  1015.              See Also
  1016.         
  1017.              com_set_carrier_vector com_set_dsr_vector
  1018.         
  1019.               
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.         
  1027.         com_set_datasize    
  1028.         ----------------------------------------------------------------
  1029.         
  1030.         
  1031.              Summary
  1032.              
  1033.              #include <int_14.h>
  1034.         
  1035.              short com_set_set_datasize( cn, data_size);
  1036.              us cn;              The COM port to initialize 
  1037.              ul data_size;       The data size to use 
  1038.         
  1039.         
  1040.         
  1041.              Description
  1042.         
  1043.              This  function sets the data_size to the given  value.   The 
  1044.              operation  is done to the COM port, cn. Possible data  sizes 
  1045.              are 5, 6, 7, and 8 bits.
  1046.         
  1047.          
  1048.         
  1049.              Return Value
  1050.         
  1051.              This function returns a completion code of zero if all  went 
  1052.              OK, or else a negative error code will be returned.
  1053.         
  1054.         
  1055.         
  1056.              See Also
  1057.         
  1058.              com_init com_set_baud
  1059.         
  1060.               
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.         
  1068.         com_set_dsr_vector  
  1069.         ----------------------------------------------------------------
  1070.         
  1071.         
  1072.              Summary
  1073.              
  1074.              #include <int_14.h>
  1075.         
  1076.              short com_set_dsr_vector( cn, (*function)() );
  1077.              us cn;              The COM port to initialize 
  1078.              us *function;       -> the function to call
  1079.         
  1080.         
  1081.         
  1082.              Description
  1083.         
  1084.              This  function sets the vector to call whenever a change  in 
  1085.              DSR  is detected by the COM port, cn.  The vector is  called 
  1086.              with  all registers saved and the function must  not  return 
  1087.              using a iret, is must use a ret instruction.
  1088.         
  1089.          
  1090.         
  1091.              Return Value
  1092.         
  1093.              This function returns a completion code of zero if all  went 
  1094.              OK, or else a negative error code will be returned.
  1095.         
  1096.         
  1097.         
  1098.              See Also
  1099.         
  1100.              com_set_carrier_vector com_set_dsr_vector
  1101.         
  1102.               
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.         
  1110.         com_set_input  
  1111.         ----------------------------------------------------------------
  1112.         
  1113.         
  1114.              Summary
  1115.              
  1116.              #include <int_14.h>
  1117.         
  1118.              short com_set_input( cn, buffer, buffer_size );
  1119.              us cn;              The COM port to initialize 
  1120.              uc far *buffer;     -> the new buffer to use
  1121.              ui buffer_size;     The new buffer size in bytes
  1122.         
  1123.         
  1124.         
  1125.              Description
  1126.         
  1127.              This  function sets up a new input buffer for the  COM  port 
  1128.              given  by cn.  Any data that would have been placed  in  the 
  1129.              original  output  buffer is redirected to  this  new  buffer 
  1130.              area,  buffer,  and the size of the new buffer is  given  by 
  1131.              buffer_size.   The internal buffer pointers are set to  this 
  1132.              new area and also to the empty condition.
  1133.         
  1134.         
  1135.         
  1136.              Return Value
  1137.         
  1138.              This function returns a completion code of zero if all  went 
  1139.              OK, or else a negative error code will be returned.
  1140.              
  1141.         
  1142.         
  1143.              See Also
  1144.         
  1145.              com_set_output com_restore_input
  1146.               
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.         
  1154.         com_set_irq    
  1155.         ----------------------------------------------------------------
  1156.         
  1157.         
  1158.              Summary
  1159.              
  1160.              #include <int_14.h>
  1161.         
  1162.              short com_set_irq( cn, irq_number );
  1163.              us cn;              The COM port to initialize 
  1164.              uc irq_number;      The IRQ number to use 
  1165.         
  1166.         
  1167.         
  1168.              Description
  1169.         
  1170.              This function sets the IRQ number of the COM port cn to  the 
  1171.              value specified in irq_number.  Valid IRQ numbers are 3  and 
  1172.              4.  
  1173.         
  1174.         
  1175.         
  1176.              Return Value
  1177.         
  1178.              This function returns a completion code of zero if all  went 
  1179.              OK, or else a negative error code will be returned.
  1180.         
  1181.         
  1182.         
  1183.              See Also
  1184.         
  1185.              com_set_id com_set_port 
  1186.         
  1187.               
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.         
  1195.         com_set_output 
  1196.         ----------------------------------------------------------------
  1197.         
  1198.         
  1199.              Summary
  1200.              
  1201.              #include <int_14.h>
  1202.         
  1203.              short com_set_output( cn, buffer, buffer_size );
  1204.              us cn;              The COM port to initialize 
  1205.              uc far *buffer;     -> the new buffer to use
  1206.              ui buffer_size;     The new buffer size in bytes
  1207.         
  1208.         
  1209.         
  1210.              Description
  1211.         
  1212.              This  function sets up a new output buffer for the COM  port 
  1213.              specified  by cn.  Any data that would have been  placed  in 
  1214.              the original output buffer is redirected to this new  buffer 
  1215.              area,  buffer,  and the size of the new buffer is  given  by 
  1216.              buffer_size.  All of the internal buffer pointers are set to 
  1217.              the empty condition and to the new values.
  1218.         
  1219.         
  1220.         
  1221.              Return Value
  1222.         
  1223.              This function returns a completion code of zero if all  went 
  1224.              OK, or else a negative error code will be returned.
  1225.         
  1226.         
  1227.         
  1228.              See Also
  1229.         
  1230.              com_set_input com_restore_output
  1231.               
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.         
  1239.         com_set_port   
  1240.         ----------------------------------------------------------------
  1241.         
  1242.         
  1243.              Summary
  1244.              
  1245.              #include <int_14.h>
  1246.         
  1247.              short com_set_port( cn, base_port );
  1248.              us cn;              The COM port to initialize 
  1249.              ui base_port;       The base port address for the COM port
  1250.         
  1251.         
  1252.         
  1253.              Description
  1254.         
  1255.              This  function sets the base address for the given COM  num-
  1256.              ber, cn to the address defined in base_port.
  1257.         
  1258.         
  1259.         
  1260.              Return Value
  1261.         
  1262.              This function returns a completion code of zero if all  went 
  1263.              OK, or else a negative error code will be returned.
  1264.         
  1265.         
  1266.         
  1267.              See Also
  1268.         
  1269.              com_set_irq com_set_id 
  1270.         
  1271.               
  1272.  
  1273.  
  1274.  
  1275.  
  1276.  
  1277.  
  1278.         
  1279.         com_set_ri_vector   
  1280.         ----------------------------------------------------------------
  1281.         
  1282.         
  1283.              Summary
  1284.              
  1285.              #include <int_14.h>
  1286.         
  1287.              short com_set_ri_vector( cn, (*function)() );
  1288.              us cn;              The COM port to initialize 
  1289.              us *function;       -> the function to call
  1290.         
  1291.         
  1292.         
  1293.              Description
  1294.         
  1295.              This  function  sets the vector to call whenever a  ring  is 
  1296.              detected by the COM port, cn.  The vector is called with all 
  1297.              registers  saved  and the function must not return  using  a 
  1298.              iret, is must use a ret instruction.
  1299.         
  1300.          
  1301.         
  1302.              Return Value
  1303.         
  1304.              This function returns a completion code of zero if all  went 
  1305.              OK, or else a negative error code will be returned.
  1306.         
  1307.         
  1308.         
  1309.              See Also
  1310.         
  1311.              com_set_carrier_vector com_set_dsr_vector
  1312.         
  1313.               
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.         
  1321.         com_set_waiting     
  1322.         ----------------------------------------------------------------
  1323.         
  1324.         
  1325.              Summary
  1326.              
  1327.              #include <int_14.h>
  1328.         
  1329.              short com_set_baud( wait_byte, response_byte );
  1330.              uc wait_byte;            Byte to respond to
  1331.              uc response_byte;        Byte with which to respond
  1332.         
  1333.         
  1334.         
  1335.              Description
  1336.         
  1337.              This  function  sets a bye that will  trigger  an  automatic 
  1338.              response  by the COM interrupt service routine (ISR).   When 
  1339.              this  feature is enabled, whenever the ISR receives  a  byte 
  1340.              matching wait_byte, the ISR will immediately return the byte 
  1341.              provided in response_byte.
  1342.         
  1343.              If  wait_byte is a 0, this background process will be  disa-
  1344.              bled.
  1345.         
  1346.          
  1347.         
  1348.              Return Value
  1349.         
  1350.              This function returns a completion code of zero if all  went 
  1351.              OK, or else a negative error code will be returned.
  1352.         
  1353.         
  1354.         
  1355.              See Also
  1356.         
  1357.               
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.         
  1365.         com_sin   
  1366.         ----------------------------------------------------------------
  1367.         
  1368.         
  1369.              Summary
  1370.         
  1371.              #include <int_14.h>
  1372.         
  1373.              us com_sin( cn, buffer );
  1374.              us cn;              The COM port to initialize 
  1375.              uc far *buffer;     -> buffer for the input data
  1376.         
  1377.         
  1378.         
  1379.              Description
  1380.         
  1381.              This  function  gets all the bytes in the input  buffer  and 
  1382.              puts them into the buffer as a ASCIIZ string.  The bytes are 
  1383.              taken from the buffer associated with the COM port cn.
  1384.         
  1385.         
  1386.         
  1387.              Return Value
  1388.         
  1389.              This  function returns no error code, instead the number  of 
  1390.              bytes input is returned.  A bad COM port will yield a zero.
  1391.         
  1392.         
  1393.         
  1394.              See Also
  1395.         
  1396.              com_in com_snin com_qin com_ein
  1397.               
  1398.  
  1399.  
  1400.  
  1401.  
  1402.  
  1403.  
  1404.         
  1405.         com_snin  
  1406.         ----------------------------------------------------------------
  1407.         
  1408.         
  1409.              Summary
  1410.         
  1411.              #include <int_14.h>
  1412.         
  1413.              us com_snin( cn, buffer, count );
  1414.              us cn;              The COM port to initialize 
  1415.              uc far *buffer;     -> buffer for the input data
  1416.              us count;           The number of bytes to read 
  1417.         
  1418.         
  1419.         
  1420.              Description
  1421.         
  1422.              This  function  gets count number of bytes  from  the  input 
  1423.              buffer  and  puts them into the buffer as a  ASCIIZ  string.  
  1424.              The bytes are taken from the buffer associated with the  COM 
  1425.              port cn.
  1426.         
  1427.         
  1428.         
  1429.              Return Value
  1430.         
  1431.              This  function returns no error code, instead the number  of 
  1432.              bytes input is returned.  A bad COM port will yield a zero.
  1433.         
  1434.         
  1435.         
  1436.              See Also
  1437.         
  1438.              com_in com_sin com_qin com_ein
  1439.               
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.         
  1447.         com_snout 
  1448.         ----------------------------------------------------------------
  1449.         
  1450.         
  1451.              Summary
  1452.         
  1453.              #include <int_14.h>
  1454.         
  1455.              short com_snout( cn, string, count );
  1456.              ui cn;              The COM port to initialize 
  1457.              uc far *string;     -> string to output
  1458.              ui count;           number of bytes to output
  1459.         
  1460.         
  1461.         
  1462.              Description
  1463.         
  1464.              This function outputs bytes from string through the COM port 
  1465.              cn,  but allows the user to specify the number of  bytes  to 
  1466.              output  from the string given with the variable count.   The 
  1467.              bytes that are to be output are stored in the output  buffer 
  1468.              and  then the function returns, leaving the ISR to  actually 
  1469.              send the bytes in order in the background.
  1470.         
  1471.         
  1472.         
  1473.              Return Value
  1474.         
  1475.              This  function  returns a 0 if no errors  were  encountered, 
  1476.              else the proper error code is returned to the calling  func-
  1477.              tion.
  1478.         
  1479.         
  1480.         
  1481.              See Also
  1482.         
  1483.              com_out com_sout com_send_command com_qout
  1484.               
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.         
  1492.         com_sout  
  1493.         ----------------------------------------------------------------
  1494.         
  1495.         
  1496.              Summary
  1497.         
  1498.              #include <int_14.h>
  1499.         
  1500.              short com_sout( cn, string );
  1501.              us cn;              The COM port to initialize 
  1502.              uc far *string;     -> string to output
  1503.         
  1504.         
  1505.         
  1506.              Description
  1507.         
  1508.              This  function outputs a string string to the COM  port  cn.  
  1509.              As with the other output routines, the characters are stored 
  1510.              in  the  output buffer and the function  returns.   The  ISR 
  1511.              working  in  the  background takes care  of  outputting  the 
  1512.              characters from the buffer.
  1513.         
  1514.         
  1515.         
  1516.              Return Value
  1517.         
  1518.              The  function returns a 0 if no errors were  encountered  or 
  1519.              else  an  appropriate  error code if some  kind  of  problem 
  1520.              develops.
  1521.         
  1522.         
  1523.         
  1524.              See Also
  1525.         
  1526.              com_out com_snout com_send_command com_qout
  1527.               
  1528.  
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
  1534.         
  1535.         com_start_hard 
  1536.         ----------------------------------------------------------------
  1537.         
  1538.         
  1539.              Summary
  1540.              
  1541.              #include <int_14.h>
  1542.         
  1543.              short com_start_hard( cn );
  1544.              us cn;              The COM port to initialize
  1545.         
  1546.         
  1547.         
  1548.              Description
  1549.         
  1550.              This function starts hardware handshaking on the serial port 
  1551.              denoted by cn. Under this protocol the RTS/CTS signals allow 
  1552.              the  receiving system to tell the sending system if  it  can 
  1553.              handle a stream of bytes at a given time. The sending system 
  1554.              looks at RTS through CTS to see if it can send bytes, if RTS 
  1555.              is asserted byte flow is allowed.  This function will return 
  1556.              an error if Xon/Xoff handshaking is already in progress.
  1557.            
  1558.         
  1559.         
  1560.              Return Value
  1561.         
  1562.              The  function returns a 0 if no errors were  encountered  or 
  1563.              else  an  appropriate  error code if some  kind  of  problem 
  1564.              develops.
  1565.         
  1566.         
  1567.         
  1568.              See Also
  1569.         
  1570.              com_stop_hard com_start_xonxoff 
  1571.               
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.         
  1579.         com_start_xonxoff   
  1580.         ----------------------------------------------------------------
  1581.         
  1582.         
  1583.              Summary
  1584.              
  1585.              #include <int_14.h>
  1586.         
  1587.              short com_start_xonxoff( cn );
  1588.              us cn;              The COM port to initialize
  1589.         
  1590.         
  1591.         
  1592.              Description
  1593.         
  1594.              This  function starts Xon/Xoff handshaking on a serial  port 
  1595.              denoted  by cn. Under this protocol the XON an XOFF  charac-
  1596.              ters are exchanged between the sender and receiver during  a 
  1597.              data  transfer in order to control data flow so  that  bytes 
  1598.              are not overwritten at the receiving end. This function will 
  1599.              return  an error if hardware handshaking is  already  imple-
  1600.              mented.
  1601.           
  1602.         
  1603.         
  1604.              Return Value
  1605.         
  1606.              The  function returns a 0 if no errors were  encountered  or 
  1607.              else  an  appropriate  error code if some  kind  of  problem 
  1608.              develops.
  1609.         
  1610.         
  1611.         
  1612.              See Also
  1613.         
  1614.              com_start_hard com_stop_xonxoff 
  1615.               
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.         
  1623.         com_status     
  1624.         ----------------------------------------------------------------
  1625.         
  1626.         
  1627.              Summary
  1628.         
  1629.              #include <int_14.h>
  1630.         
  1631.              us com_status( cn );
  1632.              us cn;              The COM number to initialize 
  1633.         
  1634.         
  1635.         
  1636.              Description
  1637.         
  1638.              This function gets the status of the given port.  It returns 
  1639.              the  current  status of the modem register  and  information 
  1640.              about error that could be occurring.  The bits of the status 
  1641.              word will be described below
  1642.         
  1643.         
  1644.              
  1645.              Return Value
  1646.         
  1647.              The function returns the com port status word, and the  bits 
  1648.              of this word have the following meanings:
  1649.         
  1650.              BIT            DESCRIPTION                   DEF.
  1651.         
  1652.               0        Change in CTS since check     COM_CHANGE_CTS
  1653.               1        Change in DSR since check     COM_CHANGE_DSR
  1654.               2        Change in RI since check      COM_CHANGE_RI
  1655.               3        Change in DCD since check     COM_CHANGE_DCD
  1656.               4        Clear to send asserted        COM_CTS
  1657.               5        Data set ready asserted       COM_DSR
  1658.               6        Ring indicator asserted       COM_RI
  1659.               7        Data Carrier Detect asserted  COM_DCD
  1660.         
  1661.               8        Data is ready to be output    COM_DATA_READY
  1662.               9        Received byte was overwritten COM_DATA_OVERRUN
  1663.              10        Parity error was detected     COM_PARITY_ERROR
  1664.              11        Transmission was out of sync  COM_FRAME_ERROR
  1665.              12        Break signal was received     COM_BREAK_DETECT
  1666.              13        Transmission register empty   COM_XMIT_EMPTY
  1667.              14        Transmission shift empty      COM_SHIFT_EMPTY
  1668.              15        General COM error since check COM_ERROR
  1669.         
  1670.         
  1671.         
  1672.              See Also
  1673.         
  1674.              com_init com_get_settings
  1675.               
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682.         
  1683.         com_stop  
  1684.         ----------------------------------------------------------------
  1685.         
  1686.         
  1687.              Summary
  1688.              
  1689.              #include <int_14.h>
  1690.         
  1691.              short com_stop( cn );
  1692.              us cn;              The COM port to initialize
  1693.         
  1694.         
  1695.         
  1696.              Description
  1697.         
  1698.              This  function  replaces the ISR that  com_init()  installed 
  1699.              with  the  original vector.  This is important  since  other 
  1700.              programs  will probably not work properly if the  system  is 
  1701.              not returned to original since they will expect the original 
  1702.              vector to be in place.
  1703.         
  1704.         
  1705.         
  1706.              Return Value
  1707.         
  1708.              The  function returns a 0 if no errors were  encountered  or 
  1709.              else  an  appropriate  error code if some  kind  of  problem 
  1710.              develops.
  1711.         
  1712.         
  1713.         
  1714.              See Also
  1715.         
  1716.              com_init 
  1717.               
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.  
  1724.         
  1725.         com_stop_hard  
  1726.         ----------------------------------------------------------------
  1727.         
  1728.         
  1729.              Summary
  1730.              
  1731.              #include <int_14.h>
  1732.         
  1733.              short com_stop_hard( cn );
  1734.              us cn;              The COM port to initialize
  1735.         
  1736.         
  1737.         
  1738.              Description
  1739.         
  1740.              This function stops hardware handshaking on the serial  port 
  1741.              denoted by cn. Under this protocol the RTS/CTS signals allow 
  1742.              the  receiving system to tell the sending system if  it  can 
  1743.              handle  a stream of bytes at a given time. The function  has 
  1744.              no effect if the handshaking was not already started.
  1745.                 
  1746.         
  1747.         
  1748.              Return Value
  1749.         
  1750.              The  function returns a 0 if no errors were  encountered  or 
  1751.              else  an  appropriate  error code if some  kind  of  problem 
  1752.              develops.
  1753.         
  1754.         
  1755.         
  1756.              See Also
  1757.         
  1758.              com_start_hard 
  1759.               
  1760.  
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.         
  1767.         com_stop_xonxoff    
  1768.         ----------------------------------------------------------------
  1769.         
  1770.         
  1771.              Summary
  1772.              
  1773.              #include <int_14.h>
  1774.         
  1775.              short com_stop_xonxoff( cn );
  1776.              us cn;              The COM port to initialize
  1777.         
  1778.         
  1779.         
  1780.              Description
  1781.         
  1782.              This  function stops Xon/Xoff handshaking on a  serial  port 
  1783.              denoted  by cn. Under this protocol the XON an XOFF  charac-
  1784.              ters are exchanged between the sender and receiver during  a 
  1785.              data  transfer in order to control data flow so  that  bytes 
  1786.              are not overwritten at the receiving end.  This function has 
  1787.              no effect when Xon/Xoff handshaking has not been started.
  1788.           
  1789.         
  1790.         
  1791.              Return Value
  1792.         
  1793.              The  function returns a 0 if no errors were  encountered  or 
  1794.              else  an  appropriate  error code if some  kind  of  problem 
  1795.              develops.
  1796.         
  1797.         
  1798.         
  1799.              See Also
  1800.         
  1801.              com_start_xonxoff 
  1802.               
  1803.  
  1804.  
  1805.  
  1806.  
  1807.  
  1808.  
  1809.         
  1810.         com_version    
  1811.         ----------------------------------------------------------------
  1812.         
  1813.         
  1814.              Summary
  1815.              
  1816.              #include <int_14.h>
  1817.         
  1818.              ui com_version( void );
  1819.         
  1820.         
  1821.         
  1822.              Description
  1823.         
  1824.              This function returns the version number of the ISR that  is 
  1825.              installed  and  operating on the system at the time  of  the 
  1826.              call.
  1827.         
  1828.         
  1829.         
  1830.              Return Value
  1831.         
  1832.              The function returns the major version number in the  MSByte 
  1833.              and the minor version number in the LSByte.
  1834.         
  1835.         
  1836.         
  1837.              See Also
  1838.         
  1839.              com_status com_init com_get_settings
  1840.               
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.         
  1848.         cprint
  1849.         -----------------------------------------------------------------
  1850.         
  1851.         
  1852.              Summary
  1853.         
  1854.              #include <int_14.h>
  1855.         
  1856.              int cprint( control_string, var1, var2, ..., varn );
  1857.         
  1858.              uc *control_string;           -> Cprint control string
  1859.              var1, var2, var3...           Various arguments for stack
  1860.         
  1861.         
  1862.         
  1863.              Description
  1864.         
  1865.              This is a general purpose display routine that operates much 
  1866.              like  the  printf function.  It supports a majority  of  the 
  1867.              control characters that printf does as well as some extended 
  1868.              features.   The output of this function is directed  to  the 
  1869.              console  or the COM port.  Also, ANSI commands are  used  to 
  1870.              provide  a  number of useful features  that  are  accessable 
  1871.              through the % and \ commands.
  1872.         
  1873.              Several  user  oriented global variables are  used  by  this 
  1874.              function:
  1875.         
  1876.                   _Cprint_Cn          Specifies  the  COM  port  to  use.
  1877.                                           The default is COM1.
  1878.         
  1879.                   _Com_Cprint_Output  The  output  device  to  use:  1  =
  1880.                                           console,  2  = COM  port,  3  = 
  1881.                                           Both.
  1882.         
  1883.              The following control sequences are supported:
  1884.         
  1885.                   %%   This sends a single % character, length can not be 
  1886.                        specified, to the output device. 
  1887.         
  1888.                   %a   Sets  the ANSI attribute to the next arguement  in
  1889.                        the list.
  1890.         
  1891.                   %b   Outputs  the next value in the argument list as  a 
  1892.                        binary number.
  1893.         
  1894.                   %c   Outputs the next value in the argument list as  an 
  1895.                        ASCII character.  Any number of characters may be 
  1896.                        sent using this control character.
  1897.         
  1898.                   %d   Outputs the next argument in the list as a decimal
  1899.                        number.
  1900.         
  1901.                   %e   This clears to the end of the line.
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.         
  1909.         cprint   (cont.)
  1910.         -----------------------------------------------------------------
  1911.         
  1912.                   %f   Outputs  the next value in the argument list as  a 
  1913.                        double precision floating point number.
  1914.         
  1915.                   %g   Outputs  the next value in the argument list as  a 
  1916.                        double precision floating point number.
  1917.         
  1918.                   %h   This  defines a place holder to be used  for  data 
  1919.                        entry.
  1920.         
  1921.                   %i   This is for data input from the user (needs data 
  1922.                        type and variable pointer).
  1923.         
  1924.                   %j   This  moves  the ANSI cursor forward a  number  of 
  1925.                        places.  
  1926.         
  1927.                   l    This  is  a modifier that can be used with  the  % 
  1928.                        control characters.  When it is used with %d,  %x, 
  1929.                        %X,  %j, or %p a long number is assumed to  be  in
  1930.                        the arguement list.  And, when it is used with a 
  1931.                        %s, a far * is assumed to point the string.
  1932.         
  1933.                   %o   The next argument in the argument list defines the 
  1934.                        output  device  to use.  ( 1 = CONSOLE,  2  =  COM
  1935.                        port, and 3 = SEND_TO_BOTH ) 
  1936.              
  1937.                   %p   Positions the ANSI cursor at the absolute location
  1938.                        indicated by the next two arguments. These values 
  1939.                        are ordered X, Y.
  1940.         
  1941.                   %r   This  restores the cursor position to is  original 
  1942.                        position.
  1943.         
  1944.                   %s   Outputs the string pointed to by the next value 
  1945.                        in the argument list.
  1946.         
  1947.                   %t   Saves  the current cursor position so that it  may
  1948.                        be restored.
  1949.         
  1950.                   %u   Outputs  the  next  arguement in the  list  as  an
  1951.                        unsigned integer.
  1952.         
  1953.                   %v   Outputs a number of bytes from the pointer provid-
  1954.                        ed,  given that the number is less than 255.   The
  1955.                        number  of bytes is specified and the string  need
  1956.                        not be terminated.
  1957.              
  1958.                   %x   Outputs the next value in the argument list as a 
  1959.                        lower case hexadecimal number.
  1960.         
  1961.                   %A   This control character will assert the DTR  signal
  1962.                        of the COM port.
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.         
  1970.         cprint   (cont.)
  1971.         -----------------------------------------------------------------
  1972.         
  1973.                   %B   This  will  start handshaking using  the  Xon/Xoff
  1974.                        protocol   unless   handshaking  is   already   in
  1975.                        progress.
  1976.         
  1977.                   %C   The next arguement in the list will define the COM 
  1978.                        port that will recieve output from Cprint.
  1979.         
  1980.                   %D   This control character will cause a the DTR signal
  1981.                        to be dropped.
  1982.         
  1983.                   %H   This  control will cause hardware  handshaking  to
  1984.                        start using RTS/CTS signals provided that other
  1985.                        handshaking is not in progress.
  1986.         
  1987.                   %S   Stops all handshaking that is in progress and  has 
  1988.                        no effect if there is no handshaking enabled.
  1989.         
  1990.                   %T   The next value in the argument list is taken to be 
  1991.                        the  number  of ticks to wait  before  a  function
  1992.                        timeout occurs.  This is just a local timeout for
  1993.                        this function call and does not affect global var-
  1994.                        iables.
  1995.         
  1996.                   %X   Outputs the next value in the argument list as a 
  1997.                        upper case hexadecimal number.
  1998.         
  1999.                   1-99 Indicates display length required for the display
  2000.                        of whatever control with which this is associated.
  2001.         
  2002.                    *   Indicates that the output length should be taken
  2003.                        from the next value in the argument list.
  2004.         
  2005.                    .   When used with a floating point number, the number
  2006.                        that immediately follows this period will indicate
  2007.                        the number of decimals to display.
  2008.         
  2009.         
  2010.              The following special characters are supported:
  2011.         
  2012.                    \b  Backspace over the previous character without
  2013.                        erasing that character. 
  2014.         
  2015.                    \f  Clears the entire screen.
  2016.         
  2017.                    \n  Carriage return, line feed.
  2018.         
  2019.                    \r  Moves to the first column of the current line.
  2020.         
  2021.                    \t  Tab character.
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.         
  2029.         cprint   (cont.)
  2030.         -----------------------------------------------------------------
  2031.         
  2032.              Return Value
  2033.         
  2034.              The  command string is sent out to the COM  port  specified, 
  2035.              and  to the Console if that is desired, or both.  The  other 
  2036.              functions specified by %control characters are performed and 
  2037.              any error that is found will be returned as such.  The value 
  2038.              of  0 will be returned if all went OK, and  the  appropriate 
  2039.              negative  error  code  will be returned  if  something  went 
  2040.              amiss.
  2041.         
  2042.         
  2043.              See Also